<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>意达设计</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../css/member.css"/>
<style>

</style>

</head>
<body class="body">

<!-- header -->
<div class="searchHeader">
	<a href="javascript:void(0);" onclick="api.closeWin();"></a>
	<input type="text" id="key" placeholder="请输入搜索内容">
    <a href="javascript:void(0)" class="searchlink">搜索</a>
</div>

<div class="screenlist">
	<a href="javascript:void(0);" class="sernli" onclick="goodsort(0)"><span>综合</span><i class="cns1"></i></a>
	<a href="javascript:void(0);" class="sernli" onclick="goodsort(1)"><span>价格</span><i class="cns2"></i></a>
	<a href="javascript:void(0);" class="sernli" onclick="goodsort(2)"><span>销量</span><i class="cns2"></i></a>
	<a href="javascript:void(0);" class="sernli" onclick="sreentPaly();"><span>筛选</span><i class="cns3"></i></a>
</div>

<div class="prolist">
    <ul id='con'>
        
        <li>
            <a href="javascript:void(0);"><img src="../image/index/img-017.jpg"></a>
            <p>莱夫时尚单肩斜跨女包</p>
            <span>HELEN手提女包新品上市，全新上市新品</span>
        </li>
        
    </ul>
</div>
<div class="clearfix" style="margin-bottom: .4rem;"></div>

<!-- 2018-12-10 -->
<div class="screenBox">
    <div class="nollbox"></div>
    <div class="screen">
        <div class="scretit">筛选</div>
        <div class="srelist">
            <div class="tittop"><span>材质</span><i></i></div>
            <div class="liesah">
                <ul id='material'>
                    <li class="liesah_on">不限<i></i></li>
                    <li>真皮<i></i></li>
                    <li>人造革<i></i></li>
                    <li>帆布<i></i></li>
                </ul>
            </div>
        </div>
        <div class="srelist">
            <div class="tittop"><span>品牌</span><i></i></div>
            <div class="liesah">
                <ul id='brand'>
                    <li class="liesah_on">不限<i></i></li>
                    <li>品牌1<i></i></li>
                    <li>品牌2<i></i></li>
                    <li>品牌3<i></i></li>
                    <li>品牌4<i></i></li>
                </ul>
            </div>
        </div>
        <div class="srelist">
            <div class="tittop"><span>品类</span><i></i></div>
            <div class="liesah">
                <ul id='cate'>
                    <li class="liesah_on">不限<i></i></li>
                    <li>挎包<i></i></li>
                    <li>背包<i></i></li>
                    <li>手包<i></i></li>
                    <li>单肩背包<i></i></li>
                </ul>
            </div>
        </div>
        <div class="srelast">
            <div class="tittop"><span>价格区间（元)</span></div>
            <div class="inpquer">
               <!--  <input type="digit" name="" placeholder="最低价">
               <span> - </span>
               <input type="digit" name="" placeholder="最高价">
                -->
                <input type="digit" name="minprice" id="minprice" placeholder="最低价">
                <span> - </span>
                <input type="digit" name="maxprice" id="maxprice" placeholder="最高价">
            </div>
        </div>

        
        <div class="srenfooter">
            <a href="javascript:void(0)" onclick="resutPlay();">取消选择</a>
            <a href="javascript:void(0)" class="btnStyle" onclick="doFilter()">确定</a>
        </div>
    </div>
</div>
<!-- end 2018-12-10 -->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="../script/adaptive.js"></script>
<script type="text/javascript" src="../script/swiper.min.js"></script>
<script type="text/javascript" src="../script/tabs.js"></script>
<script type="text/javascript">
    window['adaptive'].desinWidth = 750;
    window['adaptive'].baseFont = 28;
    window['adaptive'].maxWidth = 750;
    window['adaptive'].init();


    var page=1;
    var p='';
    var para='';

    var type='';
    var id=0;
    var sort=0;
    var updown=0;
    
    var zh=0;
    var price=0;
    var salenum=0;

    var filter=0;

    apiready = function () {
        $api.fixStatusBar($api.dom('.header'));
        api.addEventListener({
            name: 'keyback'
        }, function(ret, err){
            api.closeWidget();
        });
        api.showProgress();


        para=api.pageParam;

        type=para.type
        id=para.id
        
       /* if(id>0){
            p= {type:type,id:id,page:page};
        }else{
            p= {type:type,page:page};
        }*/

        

        toDoRequest();

        api. addEventListener({name:'scrolltobottom'}, function(ret, err){

            if(filter==1){

                doFilter()

            }else{
                toDoRequest();
            }
            

        });
        
        
        attribute()

    };

    $('.searchlink').click(function(){
        var key=$('#key').val();
        if(key==""){
            alert('请输入搜索内容');return;
        }
        var p={type:3,token:token,key:key};
        api.ajax({
            url: webSiteUrl+'/app/user/history',
            method: 'post',
            data: {
                
                values: p
            }
        }, function(ret, err) {
            
            
            if(ret.code==200){
                searchPlay(key);
               

            }else{
                alert(ret.msg)
            }
        });
        
    });

    function attribute (){

        var p={token:token};

        api.ajax({
            url: webSiteUrl+'/app/public/attribute',
            method: 'post',
            data: {
                values:p,
            }
        }, function(ret, err) {
            api.hideProgress();
            
            if(ret.code==200){
                
                //alert(ret.msg);
              
                html = '<li class="mid liesah_on" data="0">不限<i></i></li>';
                var tj=ret.data.material;
for(var i=0;i<tj.length;i++){
html+='<li class="mid" data="'+tj[i].id+'">'+tj[i].name+'<i></i></li>';
}
$('#material').html(html);

                html = '<li class="bid liesah_on" data="0">不限<i></i></li>';
                var tj=ret.data.brand;
for(var i=0;i<tj.length;i++){
html+='<li class="bid" data="'+tj[i].id+'">'+tj[i].name+'<i></i></li>';
}
$('#brand').html(html);

                html = '<li class="cid liesah_on" data="0">不限<i></i></li>';
                var tj=ret.data.cate;
for(var i=0;i<tj.length;i++){
html+='<li  class="cid" data="'+tj[i].id+'">'+tj[i].name+'<i></i></li>';
}
$('#cate').html(html);
                
            }else{
                //alert(ret.msg)
            }

        });
    }


    function toDoRequest(){
        
        p= {type:type,id:id,page:page,sort:sort,updown:updown};
        api.ajax({
                url: webSiteUrl+'/app/public/getgoods',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();
                
                if(ret.code==200){
                    //alert(ret.data.length);return;
                    html = "";
                    var tj=ret.data;
                    if(tj != null){

                    for(var i=0;i<tj.length;i++){
                        html+= '<li onclick="detailPlay('+tj[i].id+')"><a href="javascript:void(0);"><img src="'+webSiteUrl+tj[i].icon+'"></a><p>'+tj[i].name+'</p><span>'+tj[i].content+'</span></li>';
                    }
                    }
                    if(page==1){
                        $('#con').html(html);
                    }else{
                        $('#con').append(html);
                    }
                    page++;
                    //alert(JSON.stringify(p));
                }else{
                    //alert(ret.msg)
                }
            });
       
    }

    function doFilter(){
        filter=1;
        page=1;

        var mid=$('#material .liesah_on').attr('data');
        var bid=$('#brand .liesah_on').attr('data');
        var cid=$('#cate .liesah_on').attr('data');

        var patrn = /^[0-9]*$/;
        var minp=$('#minprice').val();
        var maxp=$('#maxprice').val();
        
        if(minp== ''){
            var minprice=0;
        }else if(! patrn.test(minp)){
            alert("价格必须是数字");return;
        }else{
            var minprice=minp;
        }
        if(maxp==''){
            var maxprice=999999999;
        }else if(! patrn.test(maxp)){
            alert("价格必须是数字");return;
        }else{
            var maxprice=maxp;
        }
        
    var p= {type:type,id:id,page:page,sort:sort,updown:updown,mid:mid,bid:bid,cid:cid,minprice:minprice,maxprice:maxprice};
    //alert(JSON.stringify(p));return;
        api.ajax({
                url: webSiteUrl+'/app/public/getgoods',
                method: 'post',
                data: {
                    values: p
                }
            }, function(ret, err) {
                api.hideProgress();
                resutPlay();
                if(ret.code==200){
                    //alert(ret.data.length);return;
                    html = "";
                    var tj=ret.data;
                    if(tj != null){

                    for(var i=0;i<tj.length;i++){
                        html+= '<li onclick="detailPlay('+tj[i].id+')"><a href="javascript:void(0);"><img src="'+webSiteUrl+tj[i].icon+'"></a><p>'+tj[i].name+'</p><span>'+tj[i].content+'</span></li>';
                    }
                    }
                    if(page==1){
                        $('#con').html(html);
                    }else{
                        $('#con').append(html);
                    }
                    page++;
                    //alert(JSON.stringify(p));
                }else{
                    if(page==1){
                        $('#con').html('<p style="text-align:center">暂无数据</p>');
                    }
                }
            });
       
    }
   
    function goodsort(num) {
        
        page=1;
        sort=num;
        
        if(num==0){
            zh=zh==0?1:0;
            updown=zh;

        }else if(num==1){
            price=price==0?1:0;
            updown=price;

        }else if(num==2){
            salenum=salenum==0?1:0;
            updown=salenum;
        }
        

        
        toDoRequest()
    }


    function sreentPaly () {
        $(".screenBox").show();
        $("body").addClass('overHide');
    }
    $(".nollbox").click(function(event) {
        $(".screenBox").hide();
        $("body").removeClass('overHide');
    });
    $(".tittop").click(function(event) {
        $(this).siblings('.liesah').slideToggle();
    });
    $(document).on('click', '.liesah ul li', function(event) {
        $(this).addClass('liesah_on').siblings().removeClass('liesah_on');
    });
    function resutPlay(){
        $(".liesah ul li").removeClass('liesah_on');
        $(".screenBox").hide();
        $("body").removeClass('overHide');
    }
    $(".inpquer > input").focus(function(event) {
        $(".liesah").slideUp();
    });


  

</script>

</html>
